import { Router } from 'express';
import {UpLoad, FILE} from '~/utils';
/*
import Config from '~/config';
*/

const router = Router();
/*
let {
  Local,
} = Config;
*/

router.post('/', UpLoad.single('reimbursement_image'), function (req, res, next) {
  console.log((new Date()).toLocaleString() + '  ' + req.ip + '  ' + req.url + '  接受文件：' + req.file.filename);
  res.send({
    filename: req.file.filename,
  });
});

router.delete('/:_filename', function (req, res, next) {
  try {
    FILE.remove('/image/reimbursement/' + req.params._filename);
    res.send({
      type: 'success',
      filename: req.params._filename,
    });
  } catch (err) {
    res.send({
      type: 'error',
      filename: '',
    });
  }
});

export default router;
